;;; init-python.el --- python config -*- lexical-binding:t -*-
;;; Commentary:
;;; Code:
(use-package python
  :defer t
  :ensure nil
  :delight "π "
  :mode "\\.py\\'"
  :config
  (when (and (executable-find "python3")
             (string= python-shell-interpreter "python"))
    (setq python-shell-interpreter "python3"))
  )

;; pip
(use-package pip-requirements
  :defer t)

;; py-isort
(use-package py-isort
  :defer t
  :hook (before-save . py-isort-before-save))

;; virtualenvwrapper
(use-package virtualenvwrapper
  :defer t
  :config
  (venv-initialize-interactive-shells)
  (venv-initialize-eshell)
  (setq venv-location "~/.envs")
  (setq-default mode-line-format (cons '(:exec venv-current-name) mode-line-format)))

;; python-mode-map
(leader-key python-mode-map
  "m" '(:ignore t :wk "lang")
  "mx" '(:quickrun :wk "compile")
  "mv" '(:ignore t :wk "virtualenv")
  "mvo" '(venv-workon :wk "workon")
  "mve" '(venv-deactivate :wk "deactivate")
  "mvk" '(venv-mkvirtualenv :wk "mkvirtualenv")
  "mvr" '(venv-rmvirtualenv :wk "rmvirtualenv")
  "mvd" '(venv-cdvirtualenv :wk "cdvirtualenv")
  "mvc" '(venv-cpvirtualenv :wk "cpvirtualenv")
  "mvl" '(venv-lsvirtualenv :wk "lsvirtualenv")
  "mvs" '(venv-set-location :wk "set location")
  )

(provide 'init-python)
;;; init-python.el ends here
